import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2023-10-19
 * Time: 23:45
 */
public class Solution {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            if (n <= 2) {
                System.out.println(-1);
            } else {
                // 找规律就能发现 4 个一循环
                int[] arr = {4, 2, 3, 2};
                System.out.println(arr[(n-2)%4]);
            }
        }
    }
}
